syntax on
set fileencodings=utf-8,ucs-bom,cp936,big5

set guioptions-=T
set fileencoding=utf-8
set autochdir " 自动切换当前目录为当前文件所在的目录

set autoindent
autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set sw=4
autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set ts=4
autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set sts=4
autocmd FileType javascript,html,css,xml,javascriptreact,tsx,typescript set sw=2
autocmd FileType javascript,html,css,xml,javascriptreact,tsx,typescript set ts=2
autocmd FileType javascript,html,css,xml,javascriptreact,tsx,typescript set sts=2
let mapleader=" "

" 设置快捷键，关闭一个窗口
map <leader>wq :wq<CR>


set expandtab
set number
filetype on
set autoindent
set smartindent
set showmatch
set ruler
set guifont=Consolas:h14

 
call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/fzf', { 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
call plug#end()

nnoremap <silent> <expr> <Leader><Leader> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":FZF\<cr>"
" fzf
" Mapping selecting mappings
nnoremap <silent> <Leader>f :Files<CR>
nnoremap <silent> <Leader>b :Buffers<CR>
" fzf end

" nerdtree config
" 文件树设置 {{{
" 关闭NERDTree快捷键
map <leader>t :NERDTreeToggle<CR>
autocmd vimenter * NERDTree
let NERDTreeShowBookmarks=1
""当NERDTree为剩下的唯一窗口时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
""修改树的显示图标
let NERDTreeAutoCenter=1
" 显示行号
let NERDTreeShowLineNumbers=1
" 是否显示隐藏文件
let NERDTreeShowHidden=1
" 设置宽度
let NERDTreeWinSize=25
" 在终端启动vim时，共享NERDTree
let g:nerdtree_tabs_open_on_console_startup=1
" 忽略一下文件的显示
let NERDTreeIgnore=['\.pyc','\~$','\.swp']

command! -nargs=0 Prettier :CocCommand prettier.formatFile
